export default {
    namespaced: true,
    state: {
        token: uni.getStorageSync('UgoToken') || '',
        userInfo: uni.getStorageSync('userInfo')||{},
        shippingAddress: uni.getStorageSync('shippingAddress') || ''
    },
    mutations: {
        setShippingAddress(state, data) {
            state.shippingAddress = data
            uni.setStorageSync('shippingAddress', data);
        },
        setToken(state, userInfo) {
            for (const key in userInfo) {
                if (key === 'token') {
                    state.token = userInfo[key]
                } else {
                    state.userInfo[key] = userInfo[key]
                }
            }
            uni.setStorageSync('UgoToken',state.token)
            uni.setStorageSync('userInfo',state.userInfo)
        }
    },
    actions: {},
}